<template>
  <div>
    <!-- {{JSON.stringify(item.fieldName)}} -->
    <template v-if="item.fieldName === 'formNo'">
      <template>
        <a
          href=""
          class="view-detail-btn task-list-numbering"
          @click.stop.prevent="openPassTab(scope.row)"
        >
          {{ scope.row[item.fieldName] }}
        </a>
      </template>
    </template>
    <template v-else-if="item.fieldName === 'createUser'">
      {{ scope.row[fieldString]}}
    </template>
    <template v-else-if="item.fieldName === 'customStatus'">
      {{ scope.row[item.fieldName] | formatStatus }}
    </template>
    <template v-else-if="item.fieldName === 'tagList'">
      {{ scope.row[item.fieldName] | formatTagList }}
    </template>
    <template v-else-if="item.fieldName === 'createTime'">
      {{ scope.row[item.fieldName] | fmt_datetime}}
    </template>
    <template v-else>
      {{ scope.row[item.fieldName] }}
    </template>
  </div>
</template>

<script>
import moment from 'moment'
import { openAccurateTab } from '@src/util/platform'
import { PageRoutesTypeEnum } from 'pub-bbx-global/pageType/dist/enum/PageRoutesEnum'
export default {
  props: {
    item: {
      type: Object,
      default: () => ({}),
    },
    scope: {
      type: Object,
      default: () => ({}),
    },
  },
  filters: {
    formatStatus(value) {
      return value.join(',')
    },
    formatTagList(value) {
      return value.map(item => item.tagName).join(',')
    },
    fmt_datetime(val){
      return moment(val).format('YYYY-MM-DD HH:mm:ss')
    }
  },
  methods: {
    openPassTab({id, formNo, formTemplateName, formContentId, processId = '111'}) {
  
      if (!id) return;

      let fromId = window.frameElement?.getAttribute('id') ?? '';
      openAccurateTab({
        type:PageRoutesTypeEnum.PagePaasTemplateDetail,
        key:formNo,
        titleKey:`${formTemplateName}${formNo || ''}`,
        params:`formContentId=${formContentId}&processId=${processId}`,
        fromId
      })
    },
  }
};
</script>

<style lang="scss" scoped>
</style>